package com.diary.it.multi.datasource.instance2.controller;

import cn.hutool.json.JSONUtil;
import com.diary.it.multi.datasource.instance2.model.User;
import com.diary.it.multi.datasource.instance2.model.User2;
import com.diary.it.multi.datasource.instance2.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author it
 * @Description TODO
 * @Date 2021/9/14 10:32
 * @Version 1.0
 */
@RestController
public class TestController {

    @Autowired
    private UserService userService;

    @RequestMapping("/user/list")
    public void printUser() {
        List<User> users = userService.userList1();
        System.out.println("主数据库用户数据：" + JSONUtil.toJsonStr(users));
        System.out.println("=------------------------------");
        List<User2> user2s = userService.userList2();
        System.out.println("副数据库用户数据：" + JSONUtil.toJsonStr(user2s));
    }

}
